package lab6;

import java.util.Scanner;

public class WordCount {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.nextLine();
		s=s.trim();
		System.out.println(s);
		int counter=0;
		if (isLetter(s.charAt(0))) counter++;
		for (int i = 0; i < s.length(); i++)
		{
			if (s.charAt(i)==' '&&isLetter(s.charAt(i+1))) counter++;
		}
		sc.close();
		System.out.println(counter);
//		System.out.println(s.split(" ").length);
	}
	private static boolean isLetter(char l)
	{
		return (l>='a'&&l<='z')||(l>='A'&&l<='Z');
	}

}
